package com.cloud.drore.eboss.supplier.mapper;

import com.cloud.drore.eboos.common.base.MyMapper;
import com.cloud.drore.eboos.common.entity.supplier.po.CombinationProductQueryPo;
import com.cloud.drore.eboos.common.entity.supplier.vo.CombinationProductVo;
import com.cloud.drore.eboss.supplier.entity.CombinationProduct;
import com.cloud.drore.eboss.supplier.entity.vo.RejectInfoVo;
import com.cloud.drore.eboss.supplier.mapper.provider.CombinationProductProvider;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 浙江卓锐科技股份有限公司 版权所有  Copyright 2018<br>
 *
 * @Description: <br>
 * @Project: eboos <br>
 * @CreateDate: Created in 2018/1/8 14:42 <br>
 * @Author: <a href="575842778@qq.com">郑永涛</a>
 */
public interface CombinationProductMapper extends MyMapper<CombinationProduct> {

    static String selectExpiredCombinationProductSql = " SELECT id,common_product_id FROM eboos_combination_product WHERE is_deleted =0 AND NOW() > term_of_validity_end_time ";

    @SelectProvider(type = CombinationProductProvider.class, method = "selectCombinationProductById")
    CombinationProductVo selectCombinationProductById(Long id);

    @SelectProvider(type = CombinationProductProvider.class, method = "findCombinationProductByParam")
    List<CombinationProductVo> findCombinationProductByParam(CombinationProductQueryPo productQueryPo);

    @Update("update eboos_combination_product set status ='${status}' where id =${id} ")
    int rejectProduct(@Param("id") Long id, @Param("status") String status);

    @UpdateProvider(type = CombinationProductProvider.class, method = "updateCombinationProductByParam")
    int updateCombinationProductByParam(CombinationProduct combinationProduct);

    @SelectProvider(type = CombinationProductProvider.class, method = "findCombinationProductByParamAndPoi")
    List<CombinationProductVo> findCombinationProductByParamAndPoi(CombinationProductQueryPo productQueryPo);

    @SelectProvider(type = CombinationProductProvider.class, method = "findCombinationProductByParamAndPoiSupplier")
    List<CombinationProductVo> findCombinationProductByParamAndPoiSupplier(CombinationProductQueryPo productQueryPo);

    @SelectProvider(type = CombinationProductProvider.class, method = "selectRejectInfoByProId")
    RejectInfoVo selectRejectInfoByProId(Long productId);

    @Select(selectExpiredCombinationProductSql)
    List<CombinationProductVo> selectExpiredCombinationProduct();

    @Select(" select * from eboos_combination_product where id = ${id} ")
    CombinationProduct selectAllColumnOfCombinationProduct(@Param("id") Long id);
}